package JZ1_二维数组中的查找;

public class Solution {
    public boolean Find(int target, int [][] array) {
        int rows = array.length;
        int lines = array[0].length;

        for (int i = rows - 1, j = 0; i >= 0 && j < lines;){

            if (array[i][j] > target){
                i--;
            }else if (array[i][j] < target){
                j++;
            }else if (array[i][j] == target){
                return true;
            }

        }
        return false;
    }

    public static void main(String[] args) {
        int[][] arr = {{1,2,8,9},{2,4,9,12},{4,7,10,13},{6,8,11,15}};
        int target = 7;
        Solution solution = new Solution();
        System.out.println(solution.Find(target, arr));

    }
}
